from basic.device.Android import Android
from airtest.core.api import *

class searchPage(Android):

    # 搜索应用的名称
    appName="com.cloudbae.lovenanning:id/app_name"
    #首页搜索框
    searchBtm="com.cloudbae.lovenanning:id/searchBgUnfold"
    # searchBtm="com.cloudbae.lovenanning:id/tvSearch"
    # 搜索输入
    searchText="com.cloudbae.lovenanning:id/etSearch"
    #打开
    dakai="com.cloudbae.lovenanning:id/open_app"
    @classmethod
    def clickSearch(self):
        self.poco(self.searchBtm).click()    #首页搜索框
        print("点击首页搜索框")

    @classmethod
    def clickhotSearch(self):
        self.poco(text='公积金')[1].click()
        print("点击公积金")

    @classmethod
    def clickdakai(self):
        self.poco(self.dakai)[0].click()
        print("点击打开")

    @classmethod
    def getAppName(self):
        aa = self.poco(self.appName)
        print(len(aa))
        listText=[]
        for i in range(0,len(aa)):
            listText.append(aa[i].get_text())
        print("-------")
        print(listText)
        return listText


    @classmethod
    def searchEvent(self, name):
        sleep(2)
        searchPage.clickSearch()  #首页搜索框
        print("点击首页搜索框")
        sleep(2)
        self.poco(self.searchText).set_text(text=name)     # 搜索输入
        self.poco(self.appName, text=name).wait(3).click()      # 搜索应用的名称
        sleep(3)

